<!DOCTYPE HTML>
<html>
<head>
    <title>Error</title>
    <link rel="stylesheet" href="/stylesheets/style.css">
    <script src="/scripts/jquery.min.js"></script>
    <link rel="stylesheet" href="/scripts/miniui/themes/default/miniui.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/icons.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/bootstrap/skin.css">
    <script src="/scripts/miniui/miniui.js"></script>
</head>
<body>
<div id="form1">
    <span style="width:80px;display:inline-block;">授权等级：</span>
    <input id="name" class="mini-textbox" style="width:155px;" required="true" value="<%= result.name%>"/>

    <span style="width:80px;display:inline-block;">上级：</span>
    <input id="fatherId" class="mini-combobox" style="width:155px;" data="<%= result.result%>" value="<%= result.levelName%>"/>
    <br/><br/>
</div>
<div style="margin: 0 auto;text-align: center">
    <a class="mini-button " iconCls="icon-ok" onclick="addUserLevel()">确定</a>
    <a class="mini-button" iconCls="icon-cancel" onclick="onCancel">取消</a>
</div>
</body>
<script>
    var objectId = '<%- result.id%>';
    mini.parse();
    function addUserLevel() {
        var form = new mini.Form("#form1");
        form.validate();
        if (form.isValid() == false) return;
        var name = mini.get("name").getValue();
        var fatherId = mini.get("fatherId").getValue();
        var fatherName = mini.get("fatherId").getText();
        $.ajax({
            type: "POST",
            url: "/getdata/addUserLevelTree",
            data: {
                objectId:objectId,
                name: name,
                fatherId: fatherId,
                fatherName:fatherName,
            },
            success: function (result) {
                CloseWindow("save");
            }
        })
    }
    //    关闭窗口
    function CloseWindow(action) {
        if (action == "close" && form.isChanged()) {
            if (confirm("数据被修改了，是否先保存？")) {
                return false;
            }
        }
        if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
        else window.close();
    }
    function onOk(e) {
        SaveData();
    }
    function onCancel(e) {
        CloseWindow("cancel");
    }

</script>
</html>